const http = require('http')
const path = require('path')
const fs = require('fs')

// 服务器端渲染 
http.createServer((req, res) => {
  let data = {
    title: '我是一个标题'
  }
  let html = fs.readFileSync(path.resolve('./template/home.html'), 'utf-8')
  html = html.replace(/\{\{\s*(\w+)\s*\}\}/g, (match, arg1) => data[arg1])
  res.end(html)
}).listen(3000, () => console.log('http://localhost:3000'))